<!--  -->
<template>
  <div id="business-district-index">
    <c-title :text="pageTitle"></c-title>
    <div class="headTop" >
      <div class="himg">
        <img :src="info.member && info.member.avatar" alt="" />
      </div>
      <div class="userBox">
        <div class="name">{{ info.member && info.member.nickname }}</div>
      </div>
    </div>

    <van-cell-group inset class="t-l" v-if="info.card && info.card.is_show_buy">
      <van-cell title="购买会员卡" :label="info.card && info.card.is_buy?`有效期：${info.card && info.card.expire_time || '--'}`:''">
        <template #right-icon	>
          <van-button @click="gotoCard" round block type="primary" size="mini" style="width: 3.75rem;" color="var(--themeBaseColor)">购买</van-button>
        </template>
      </van-cell>
    </van-cell-group>

    <van-cell-group inset class="t-l margin-top-10">
      <van-cell title="会员卡购买记录" is-link @click="toUrl('orderlist',{'status': 0,'orderType':'BusDist'})"/>
      <van-cell :title="`${fun.getPluginSetting('love.deduction_love_name','可用爱心值')}奖励记录`" is-link @click="toUrl('baseRewardTemplate',{},{api: 'plugin.business-district.frontend.controllers.index.reward-list'})"/>
      <template v-if="info.identity">
        <van-cell title="平台" is-link v-if="info.identity.includes(5)" @click="toUrl('BusDistHome',{'identity':'platform'})"/>
        <van-cell title="区域代理" is-link v-if="info.identity.includes(4)" @click="toUrl('BusDistHome',{'identity':'agent'})"/>
        <van-cell title="推广者" is-link v-if="info.identity.includes(3)" @click="toUrl('BusDistHome',{'identity':'promoter'})"/>
        <van-cell title="门店" is-link v-if="info.identity.includes(2)" @click="toUrl('BusDistHome',{'identity':'store'})"/>
        <van-cell title="店员" is-link v-if="info.identity.includes(1)" @click="toUrl('BusDistHome',{'identity':'clerk'})"/>
      </template>
    </van-cell-group>

    <van-cell-group inset class="t-l margin-top-10">
      <van-cell :title="`奖池${fun.getPluginSetting('love.deduction_love_name','可用爱心值')}总额`"
      :value="`分红时间：${info.reward && info.reward.dividend_time||'--'}`" :label="info.reward && info.reward.all_love||'0'" value-class="f-11" :border="false" label-class="f-bold f-24 color-000000"/>
      <van-row class="t-c margin-top-10">
        <van-col span="12">{{ fun.getPluginSetting('love.deduction_love_name','可用爱心值') }}</van-col>
        <van-col span="12" >{{ fun.getPluginSetting('integral.plugin_name','消费积分') }}</van-col>
      </van-row>
      <van-row class="t-c f-18 f-bold">
        <van-col span="12">{{ info.reward && info.reward.love || '0'  }}</van-col>
        <van-col span="12">{{ info.reward && info.reward.integral || '0' }}</van-col>
      </van-row>
      <div style="height: 20px;"></div>
    </van-cell-group>
  </div>
</template>

<script>
export default {
  data () {
    return {
      pageTitle: '--',
      integral: '',
      info: {},
    };
  },

  activated() {
    this.getData();
  },

  components: {},

  computed: {},

  mounted() {},

  methods: {
    async getData() {
      let { result, msg, data } = await $http.get('plugin.business-district.frontend.controllers.index.index',{},".");
      if(result == 0) return this.$toast(msg);
      this.pageTitle = data.plugin_name;
      this.fun.setWXTitle(this.pageTitle);
      this.info = data;
      this.integral = window.localStorage.getItem("integral") || "消费积分";
    },
    async gotoCard(){
      this.isLock = true;
      if(!this.isLock) return;
      let { result, msg, data } = await $http.get('plugin.business-district.frontend.controllers.order.create',{},".");
      this.isLock = false;
      if(result == 0) return this.$toast(msg);
      this.$router.push(this.fun.getUrl('orderpay',{order_ids: data.order_ids}));
    },
    toUrl(name,params={},query={}){
      if(!name) return;
      this.$router.push(this.fun.getUrl(name,params,query));
    }
  }
};

</script>
<style lang='scss' rel='stylesheet/scss' scoped>
#business-district-index{
  .headTop {
  padding: 1.5rem 0.75rem 2.875rem;
  background: linear-gradient(var(--themeBaseColor), #f5f5f5);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  .userBox {
    display: flex;
    flex-direction: column;
    margin-left: 0.41rem;
    text-align: left;
    flex: 1;
    .name {
      font-size: 1rem;
      color: #ffffff;
      font-weight: bold;
    }
  }

  .himg {
    width: 3.44rem;
    height: 3.44rem;
    border-radius: 100%;
    img {
      width: 100%;
      height: 100%;
      border-radius: 100%;
    }
  }
}
}
</style>